// var element = document.querySelector('#title');
// element.addEventListener('animationend', function () {
//     element.className = "animate__animated animate__pulse";
//     element.style.cssText = "font-size:75px;font-weight: bold;color: pink;animation-name: pulse;animation-duration: 1.5s;animation-iteration-count: infinite;animation-direction: alternate;"
// });
var max = $(".bg");
var timer = 6000;
$(".bg").eq(0).addClass("show");
$(".start").tap(function () {
    var myT = 3;
    $('.counter').text(myT).addClass('show');
    var mytimer = setInterval(function () {
        $('.counter').addClass('show');
        if (myT < 2) {
            clearInterval(mytimer);
            nextPage();
            return;

        }
        myT--;
        $(".bg").eq(0).append($('.counter').text(myT).remove());

    }, 2000);

});

function nextPage() {
    var index = 1;
    $(".bg").removeClass("show");
    $(".bg").eq(index).addClass("show");
    var max = $(".bg").length;

    var myCounter = setInterval(function () {
        if (index > max - 2) {
            clearInterval(myCounter);
            return
        }
        index++;
        $(".bg").removeClass("show");
        $(".bg").eq(index).addClass("show");
    }, timer);
}

function play(id) {
    $(document).one("click", function () {
        console.log("log", $(id)[0]);
        $(id)[0].play();
    });
}
play("#bgm");